package kr.hkit.powerjava.chapter22.work;

import java.util.ArrayList;

public class StudentManager implements DaoInterface<Student> {
	private ArrayList<Student> arList;

	public StudentManager() {

		arList = new ArrayList<>();
	}

	public StudentManager(ArrayList<Student> arList) {
		this.arList = arList;
	}

	/*
	 * public void addStudent(Student std) { arList.add(std); }
	 * 
	 * public Student searchStd(Student std) { if (arList.contains(std)) {
	 * return arList.get(arList.indexOf(std)); } else { return null; } }
	 * 
	 * public void setStudent(Student std) { arList.set(arList.indexOf(std),
	 * std);
	 * 
	 * Student temp = arList.get(arList.indexOf(std));
	 * temp.setStdNum(std.getStdNum()); temp.setStdNum(std.getStdName());
	 * temp.setStdNum(std.getKorScore()); temp.setStdNum(std.getEngScore());
	 * temp.setStdNum(std.getMathScore());
	 * 
	 * }
	 * 
	 * public void delStudent(Student std) { if (arList.contains(std)) {
	 * 
	 * arList.remove(arList.indexOf(std));
	 * 
	 * } else { System.out.println("해당 학생 음슴"); } }
	 */

	public void prnList() {
		for (Student std : arList) {
			System.out.println(std);

		}
	}

	public void prnHeader() {

		String header = String.format("%3s\t%5s\t%4s\t%4s\t%4s\t%3s\t%5s",
				"학번", "성명", "국", "영", "수", "총점", "평균");
		System.out.println(header);

	}

	@Override
	public void addItem(Student item) {
		arList.add(item);

	}

	@Override
	public Student searchitem(Student item) {
		if (arList.contains(item)) {
			return arList.get(arList.indexOf(item));
		} else {
			return null;
		}
	}

	@Override
	public void setitem(Student item) {
		arList.set(arList.indexOf(item), item);
		/*
		 * Student temp = arList.get(arList.indexOf(std));
		 * temp.setStdNum(std.getStdNum()); temp.setStdNum(std.getStdName());
		 * temp.setStdNum(std.getKorScore()); temp.setStdNum(std.getEngScore());
		 * temp.setStdNum(std.getMathScore());
		 */

	}

	@Override
	public void delitem(Student item) {
		if (arList.contains(item)) {

			arList.remove(arList.indexOf(item));

		} else {
			System.out.println("해당 학생 음슴");
		}

	}
}
